const mongoose = require("mongoose");

mongoose
	.connect("mongodb://127.0.0.1:27017/yu_qing_admin")
	.then(() => {
		// 连接成功后监听数据库错误事件.
		mongoose.connection.on("error", (e) => {
			console.log(`数据库出现错误 -> ${e?.message}`);
		});
	})
	.catch((e) => {
		console.log(`数据库连接失败 -> ${e?.message}`);
	});

module.exports = mongoose;
